<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.yaodian100.ec.member.service.MemberService"%>
<%@page import="com.yaodian100.mall.member.util.UserData"%>
<%@page import="com.yaodian100.ec.member.entity.Member"%>
<script type="text/javascript" charset="UTF-8" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery-ui-1.7.2.custom.min.js"></script>
<%	
Member member = (Member)request.getAttribute("member");
if(null == member){
	UserData userData = new UserData(request,response);
	MemberService memberService = (MemberService)WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()).getBean("memberService");
	member = memberService.getMemberByLoginId(userData.getLoginId());
}
if(member!=null&&"nonmember".equals(member.getApplySource())){ 
	if(null!=member.getActivateExpireDate()){%>
	<script language="javascript" >
			$().ready( function() {
				$("#oto_activate_submit").click(function(){
					$("#loginIDF").val($("#ologinID").val());
					$("#mailF").val($("#omail").val());
					$("#waitactivateForm").submit();
					return false;
				});
			});
	</script>
	<div class="nomember-order-end">
         <div class="join-area">
            	<p>我们已向<span class="txt-rd"><%=member.getEmail() %></span>发送验证邮件<br>
           	    请您立即登录该邮箱，并点击邮件中的链接地址，即可完成注册。</p>
               <p><a href="javascript:;" class="btn-mid-13" id="oto_activate_submit">重发验证邮件或更改其他邮箱</a></p>

            </div>
       	    <p class="nomb-msg">接著激活邮箱，就可以成为会员，<br>享受更多会员专属服务与不定期积分与礼券发放优惠！</p>
      </div>
      <input type="hidden" id="omail" value="<%=member.getEmail() %>"/>
      <input type="hidden" id="ologinID" value="<%=member.getLoginId() %>"/>
	<%}else{%>
		<script language="javascript">
			$().ready( function() {
				$("#oto_activate_submit").click(function(){
					$("#ologinIDTip").html('');
					var isCorrect = true;
					$("#ologinID").val(jQuery.trim($("#ologinID").val()).toLowerCase());
					var text = $("#ologinID").val();
					var idlength=text.length+chineseCount(text);  
					if(idlength==0){
						$("#ologinIDTip").html('<span class="msg rn">请输入帐户名</span>');
						isCorrect = false;
					}else if(idlength<4||idlength>20){
						$("#ologinIDTip").html('<span class="msg rn">帐户名长度不符规定</span>');
						isCorrect = false;
					}else if(isAllNum(text)){
						$("#ologinIDTip").html('<span class="msg rn">帐户名不能全为数字</span>');
						isCorrect = false;
					}else if(text.indexOf(' ')>=0){
						$("#ologinIDTip").html('<span class="msg rn">帐户名不能含有空白</span>');
						isCorrect = false;
					}else if(text.match(/^[\u0391-\uFFE5\w]+$/)==null){
						$("#ologinIDTip").html('<span class="msg rn">只能使用小写英文字母、中文、数字</span>');
						isCorrect = false;
					}
					if(isCorrect){
						$.post("<%=ServerValue.getFrontContextPath()%>/nonMember/goactivate.do",{mail:$("#omail").val(),loginID:$("#ologinID").val()},oactivateResult,"json");
					}
				});
			});

			function chineseCount(word){
			    var length=0;
			    for(var cc=0;cc<word.length;cc++){
			       var c = word.charCodeAt(cc);
			      if (!(c>=32&&c<=126)) length++;
			    }
			    return length;
			}

			function isAllNum(str){
				for(var i=0;i<str.length;i++){
					var c = str.charCodeAt(i);
					if(c > 57 || c < 48)
						return false;
				}
				return true;
			}

			function oactivateResult(result){			
				if(result == 'ok' ){
					$("#loginIDF").val($("#ologinID").val());
					$("#mailF").val($("#omail").val());
					$("#waitactivateForm").submit();
					return false;
				}else if(result == 'id_exist'){
					$("#ologinIDTip").html('<span class="msg rn">该帐户名已被使用</span>');
				}
			}
		</script>
				
		<div class="nomember-order-end">
         	<div class="join-area">
            	<p><strong>联络邮箱：</strong><span class="txt-rd"><%=member.getEmail() %></span></p>
            	<p><div class="f-lt"><strong>设定帐户名：</strong></div><div class="f-lt"><input size="20" maxlength="20" id="ologinID" name="loginID"/>  <span style="display:block" class="txt-gy">请用小写英文字母、中文、数字,长度2-10个汉字或4-20个字符。</span><span style="display:block" id="ologinIDTip"></span></div></p>
            	<p><a href="javascript:;" id="oto_activate_submit"><img src="/images/shoppingcar/joinbtn.gif" class="btn"></a></p>
          	</div>
       	  	<p class="nomb-msg">接著设定帐户名并激活邮箱，就可以成为会员，<br>享受更多会员专属服务与不定期积分与礼券发放优惠！</p>
      	</div>
      	<input type="hidden" id="omail" name="mail" value="<%=member.getEmail() %>"/>
<%	}
}%>